import { IPSOne2OneDataDEField } from '../defield/ipsone2-one-data-defield';
import { IPSDER11 } from './ipsder11';
import { PSDER1NImpl } from './psder1-nimpl';

export class PSDER11Impl extends PSDER1NImpl implements IPSDER11 {
  protected psone2onedatadefield: IPSOne2OneDataDEField | null = null;

  getPSOne2OneDataDEField(): IPSOne2OneDataDEField | null {
    if (this.psone2onedatadefield != null) return this.psone2onedatadefield;
    const value = this.M.getPSOne2OneDataDEField;
    if (value == null) {
      return null;
    }
    this.psone2onedatadefield = this.getPSModel4('dataentity.defield.IPSOne2OneDataDEField', value, 'getPSOne2OneDataDEField') as IPSOne2OneDataDEField;
    return this.psone2onedatadefield;
  }

  get psOne2OneDataDEField(): IPSOne2OneDataDEField | null {
    return this.getPSOne2OneDataDEField();
  }

  getPSOne2OneDataDEFieldMust(): IPSOne2OneDataDEField {
    const value = this.getPSOne2OneDataDEField();
    if (value == null) {
      throw new Error('未指定一对一关系数据属性');
    }
    return value;
  }

  get cls(): string {
    return 'PSDER11Impl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.der.IPSDER11') return true;
    return super.instanceof(cls);
  }
}
